/**
 * Copyright(c) 2025 hbswxx.com, All Rights Reserved. Author: kouqiang Create date: 2025/5/29
 */
package cn.sw.syncdata.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
/**
 * description: 心跳数据,保障同一时间,信息内容跟小区编码不重复
 *
 * @author kouqiang
 * @date 2025/5/30 17:20
 */
@Data
@TableName("heartinfo_tab")
@EqualsAndHashCode(of = {"communityIndexcode","logInfo","addtime"})
public class HeartInfo implements Serializable {
    @TableId
    private Integer id;
    private String communityIndexcode;
    private String logLevel;
    private String logInfo;
    private LocalDateTime addtime;
    private String gdcType;

//    public HeartInfo() {
//    }
//
//    public HeartInfo(HeartInfo heartInfo) {
//        this.communityIndexcode = heartInfo.getCommunityIndexcode();
//        this.logLevel = heartInfo.getLogLevel();
//        this.logInfo = heartInfo.getLogInfo();
//        this.gdcType = heartInfo.getGdcType();
//    }
    @Override
    public String toString(){
        return communityIndexcode+","+logLevel+","+logInfo+","+formatter.format(addtime);
    }
    // 重写 hashCode() 和 equals()
    @Override
    public int hashCode() {
        return Objects.hash(communityIndexcode, logInfo, addtime);
    }

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        HeartInfo other = (HeartInfo) obj;
        return communityIndexcode.equals(other.getCommunityIndexcode()) && logInfo.equals(other.getLogInfo()) && addtime.isEqual(other.getAddtime());
    }
}
